define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'form_teacher/index' + location.search,
                    add_url: 'form_teacher/add',
                    edit_url: 'form_teacher/edit',
                    del_url: 'form_teacher/del',
                    multi_url: 'form_teacher/multi',
                    table: 'form_teacher',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'openid', title: __('Openid')},
                        {field: 'nickname', title: __('Nickname')},
                        {field: 'birthday_time', title: __('Birthday_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'jobno', title: __('Jobno')},
                        {field: 'gender', title: __('Gender')},
                        {field: 'cid', title: __('Cid')},
                        {field: 'crid', title: __('Crid')},
                        {field: 'tel', title: __('Tel')},
                        {field: 'family_address', title: __('Family_address')},
                        {field: 'current_address', title: __('Current_address')},
                        {field: 'a_9', title: __('A_9')},
                        {field: 'a_10', title: __('A_10')},
                        {field: 'a_10_1', title: __('A_10_1')},
                        {field: 'a_10_2', title: __('A_10_2')},
                        {field: 'a_10_3', title: __('A_10_3')},
                        {field: 'a_10_4', title: __('A_10_4')},
                        {field: 'a_10_5', title: __('A_10_5')},
                        {field: 'a_10_6', title: __('A_10_6')},
                        {field: 'a_11', title: __('A_11')},
                        {field: 'a_11_1', title: __('A_11_1')},
                        {field: 'a_11_2', title: __('A_11_2')},
                        {field: 'a_11_3', title: __('A_11_3')},
                        {field: 'a_11_4', title: __('A_11_4')},
                        {field: 'a_11_5', title: __('A_11_5')},
                        {field: 'a_12', title: __('A_12')},
                        {field: 'a_12_1', title: __('A_12_1')},
                        {field: 'a_12_2', title: __('A_12_2')},
                        {field: 'a_12_3', title: __('A_12_3')},
                        {field: 'a_12_4', title: __('A_12_4')},
                        {field: 'a_12_5', title: __('A_12_5')},
                        {field: 'a_13', title: __('A_13')},
                        {field: 'a_14', title: __('A_14')},
                        {field: 'a_15', title: __('A_15')},
                        {field: 'a_16', title: __('A_16')},
                        {field: 'a_17', title: __('A_17')},
                        {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        sea: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'form_teacher/sea' + location.search,
                    add_url: 'form_teacher/add',
                    edit_url: 'form_teacher/edit',
                    del_url: 'form_teacher/del',
                    multi_url: 'form_teacher/multi',
                    table: 'form_teacher',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: '', title: __('序号'),operate:false,table:table,formatter: Table.api.formatter.natureorder},
                        //{field: 'openid', title: __('Openid'), operate:false},
                        {field: 'nickname', title: __('Nickname'), operate:false},
                        {field: 'birthday_time', title: __('Birthday_time'), addclass:'datetimerange', formatter: Table.api.formatter.datestr, operate:false},
                        {field: 'jobno', title: __('Jobno'), operate:false},
                        {field: 'gender', title: __('性别'), operate:false,formatter: function (value, row, index) {
                                var str = "";
                                switch(row.gender){
                                    case 0:
                                        str = '男';
                                        break;
                                    case 1:
                                        str = '女';
                                        break;
                                    default:
                                        str = '-';
                                }
                                return str;
                            }},
                        // {field: 'cid', title: __('Cid'), operate:false},
                        // {field: 'crid', title: __('Crid'), operate:false},
                        {field: 'tel', title: __('Tel'), operate:false},
                        {field: 'family_address', title: __('Family_address'), operate:false},
                        {field: 'current_address', title: __('Current_address'), operate:false},
                        {field: 'address', title: '微信地址',operate:false},
                        {field: 'a_9', title: __('近15日内是否有乘坐1小时以上密闭公共交通经历'), operate:false,formatter: Table.api.formatter.yesorno},
                        {field: 'a_10', title: __('自1月10日以来是否有武汉进出经历或接触湖北疫区'), operate:false,formatter: Table.api.formatter.yesorno},
                        {field: 'a_10_1', title: __('进入武汉或湖北疫区日期'), operate:false, formatter: Table.api.formatter.datetime},
                        {field: 'a_10_2', title: __('离开武汉或湖北疫区日期'), operate:false, formatter: Table.api.formatter.datetime},
                        {field: 'a_10_3', title: __('进出原因'), operate:false},
                        {field: 'a_10_4', title: __('交通方式（含车次、航班号）'), operate:false},
                        {field: 'a_10_5', title: __('目前自己及身边亲人身体状况是否出现异常'), operate:false,formatter: Table.api.formatter.yesorno},
                        {field: 'a_10_6', title: __('是否汇报当地居委会/村委会'), operate:false,formatter: Table.api.formatter.yesorno},
                        {field: 'a_11', title: __('是否近15日从湖北疫区抵达青岛'), operate:false,formatter: Table.api.formatter.yesorno},
                        {field: 'a_11_1', title: __('抵达日期'), operate:false, formatter: Table.api.formatter.datetime},
                        {field: 'a_11_2', title: __('交通方式（含车次/航班号）'), operate:false},
                        {field: 'a_11_3', title: __('是否在居家隔离'), operate:false,formatter: Table.api.formatter.yesorno},
                        {field: 'a_11_4', title: __('自己及身边亲人身体是否出现异常'), operate:false,formatter: Table.api.formatter.yesorno},
                        {field: 'a_11_5', title: __('是否汇报当地居委会/村委会'), operate:false,formatter: Table.api.formatter.yesorno},
                        {field: 'a_12', title: __('是否近15日从省外抵达山东'), operate:false,formatter: Table.api.formatter.yesorno},
                        {field: 'a_12_1', title: __('抵达日期'), operate:false, formatter: Table.api.formatter.datetime},
                        {field: 'a_12_2', title: __('交通方式（含车次/航班号）'), operate:false},
                        {field: 'a_12_3', title: __('是否在居家隔离'), operate:false,formatter: Table.api.formatter.yesorno},
                        {field: 'a_12_4', title: __('目前自己及身边亲人身体是否出现异常'), operate:false,formatter: Table.api.formatter.yesorno},
                        {field: 'a_12_5', title: __('是否汇报当地居委会/村委会'), operate:false,formatter: Table.api.formatter.yesorno},
                        {field: 'a_13', title: __('近15日内是否接触过确诊病例'), operate:false,formatter: Table.api.formatter.yesorno},
                        {field: 'a_14', title: __('近15日内是否接触过疑似病例或从疫区返鲁人员'), operate:false,formatter: Table.api.formatter.yesorno},
                        {field: 'a_15', title: __('近15日内直系亲属有无被确诊'), operate:false,formatter: Table.api.formatter.yesorno},
                        {field: 'a_16', title: __('目前是否在青岛农业大学校园内'), operate:false,formatter: Table.api.formatter.yesorno},
                        {field: 'a_17', title: __('人是否有发烧、干咳、乏力等异常表现'), operate:false,formatter: Table.api.formatter.yesorno},
                        // {field: 'create_time', title: __('时间'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},


                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});